package org.ky.generator.config;

import java.io.File;

/**
 * Java包配置
 * 
 * @author K.y
 *
 */
public class PackageConfig {
	/** 实体类 子包 */
	protected static String onlyModel = "model";
	/** 数据传输对象 子包 */
	protected static String onlyDto = "dto";
	/** 数据接口 子包 */
	protected static String onlyDao = "dao";
	/** CRUD接口 子包 */
	protected static String onlyMapper = "mapper";
	/** CRUD接口实现 子包 */
	protected static String onlyMapperImpl = "mapper.impl";
	/** Base子包 */
	protected static String subBasePackage = "base";
	/** BaseJson类名 */
	protected static String clsBaseJson = "BaseJson";
	/** CRUD基础接口接口 */
	protected static String clsIBaseMapper = "IBaseMapper";
	/** 自定义查询器类名 */
	protected static String clsCriteria = "DefaultCriteria";

	public static String getOnlyModel() {
		return onlyModel;
	}

	public static String getOnlyDao() {
		return onlyDao;
	}

	public static String getOnlyMapper() {
		return onlyMapper;
	}

	public static String getClsBaseJson() {
		return clsBaseJson;
	}

	public static String getModelPath() {
		return _fullPath(onlyModel);
	}

	public static String getDaoPath() {
		return _fullPath(onlyDao);
	}

	public static String getMapperPath() {
		return _fullPath(onlyMapper);
	}

	public static String getMapperImplPath() {
		return _fullPath(onlyMapperImpl);
	}

	public static String getBaseJsonPath() {
		return _fullPath(subBasePackage + "." + clsBaseJson);
	}

	public static String getIBaseMapperPath() {
		return _fullPath(subBasePackage + "." + clsIBaseMapper);
	}

	public static String getCriteriaPath() {
		return _fullPath(onlyModel + "." + onlyDto + "." + clsCriteria);
	}

	/**
	 * 拼接基础包获得完整包路径
	 * 
	 * @param subPath
	 * @return
	 */
	protected static String _fullPath(String subPath) {
		return (GeneratorCofig.getTargetPackage() + "." + subPath);
	}

	/**
	 * 生成包文件目录
	 * 
	 * @param packagePath
	 * @return
	 */
	public static File mkdirsPackagePath(String packagePath) {
		File dir = new File("target/" + packagePath.replaceAll("\\.", "/"));
		if (!dir.exists()) {
			dir.mkdirs();
		}
		return dir;
	}

}
